<template>
	<view>
		<uni-card v-for="(item,index) in works" :key="index">
			<view class="works-list">
				<!-- <view> -->
				<image src="../../static/yz-image/yzs.jpeg" style="width: 80px;height: 80px;float: left;"></image>
				<!-- </view> -->
				<view style="text-align: center;">
					<text style="font-size: 15px; color: #e65600;">《{{item.worksName}}》</text>
				</view>
				<view>
					<text>作品编号：<text v-if="item.id >=0">{{item.id}}</text> </text>
				</view>
				<view>
					<text>淘宝单号：{{item.orderId}}</text>
				</view>
				<view>
					<text>保存时间：{{item.createTime}}</text>
				</view>
				<view>
					<text>备注：{{item.remark}}</text>
				</view>
			</view>
			<view style="float: right;">
				<button type="primary" size="mini" plain @click="toUpdate(index)">继续修改</button>
			</view>
		</uni-card>
		<view v-if="works.length <= 0" style="text-align: center;line-height: 50vh;">
				暂无作品，<text style="color: #007AFF;" @click="toAddWorks">点击添加</text>
		</view>
	</view>
</template>

<script>
	export default {
		methods: {
			toAddWorks(){
				uni.navigateTo({
					url: '../addprodce/addprodce',
					success: res => {}
				});
			},
			toUpdate(index) {
				uni.navigateTo({
					url: "../addprodce/addprodce?id=" + this.works[index].id
				})
			}
		},
		onLoad() {
			uni.getStorageInfo({
				success: res => {
					let k = res.keys
					for (let i in k) {
						if(!isNaN(k[i])){
							uni.getStorage({
								key:k[i],
								success:res=>{
									this.works.push(res.data)
								}
							})
						}
					}
				}
			})
		},
		data() {
			return {
				works: []
			};
		}
	}
</script>

<style lang="scss">
	.uniCol {
		border: 1px solid red;
	}

	.works-list view {
		display: flex;
		flex-direction: column;
		padding: 2px 0 0 5px;
	}

	.works-list {
		width: 100%;
		height: 150px;
		border-bottom: 1px solid #C7C7C7;
		margin-bottom: 10px;
	}
</style>
